4110

21 分钟

#HTML 的 <math> 标签

MathML 的 <math> 元素是顶级的 MathML 元素,用于编写单个数学公式。可以将其放在允许流式内容的 HTML 内容中。

#属性

  • display: 该枚举属性指定了应如何渲染封闭的 MathML 标记。其可以是以下值之一:
    • block ,这意味着该元素将显示在当前文本范围之外的块中,并将 math-style 设置为 normal。
    • inline ,这意味着该元素将显示在当前的文本范围内,并将 math-style 设置为 compact。

#示例

圆的周长公式: <math xmlns="http://www.w3.org/1998/Math/MathML" display="block"> <mrow> <mi>C</mi> <mo>=</mo> <mn>2</mn> <mi>π</mi> <mi>r</mi> </mrow> </math> 圆的面积公式: <math xmlns="http://www.w3.org/1998/Math/MathML" display="block"> <mrow> <mi>A</mi> <mo>=</mo> <mi>π</mi> <msup> <mi>r</mi> <mn>2</mn> </msup> </mrow> </math> 球的表面积公式: <math xmlns="http://www.w3.org/1998/Math/MathML" display="block"> <mrow> <mi>S</mi> <mo>=</mo> <mn>4</mn> <mi>π</mi> <msup> <mi>r</mi> <mn>2</mn> </msup> </mrow> </math> 球的体积公式: <math xmlns="http://www.w3.org/1998/Math/MathML" display="block"> <mrow> <mi>V</mi> <mo>=</mo> <mfrac> <mn>4</mn> <mn>3</mn> </mfrac> <mi>π</mi> <msup> <mi>r</mi> <mn>3</mn> </msup> </mrow> </math> 一元二次方程 <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>a</mi> <msup> <mi>x</mi> <mn>2</mn> </msup> <mo>+</mo> <mi>b</mi> <mi>x</mi> <mo>+</mo> <mi>c</mi> <mo>=</mo> <mn>0</mn> </math> 的求根公式为 <math xmlns="http://www.w3.org/1998/Math/MathML" display="block"> <mi>x</mi> <mo>=</mo> <mfrac> <mrow> <mo>-</mo> <mi>b</mi> <mo>±</mo> <msqrt> <msup> <mi>b</mi> <mn>2</mn> </msup> <mo>-</mo> <mn>4</mn> <mi>a</mi> <mi>c</mi> </msqrt> </mrow> <mrow> <mn>2</mn> <mi>a</mi> </mrow> </mfrac> </math>

<math>

圆的周长公式: C = 2 π r 圆的面积公式: A = π r 2 球的表面积公式: S = 4 π r 2 球的体积公式: V = 4 3 π r 3 一元二次方程 a x 2 + b x + c = 0 的求根公式为 x = - b ± b 2 - 4 a c 2 a

创建于 2025/6/9

更新于 2025/6/13